package com.example.demo.service;

import com.example.demo.entity.Person;
import com.example.demo.exception.CustomException;
import com.example.demo.exception.CustomExceptionType;
import com.example.demo.mapper.PersonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service

public class TestServiceimpl implements TestService {
    @Autowired
    PersonMapper personMapper;
    @Override
    @Transactional
    public void test() {
        for (int i = 0; i < 10 ;i++) {
            Person person = new Person();
            person.setName("ee");
            person.setAge(i);
            person.setParentName("parent");
            personMapper.insert(person);
            /*if (i==6){
                throw new CustomException(CustomExceptionType.USER_INPUT_ERROR);
            }*/
        }
    }
}
